package com.community.comsys.service.impl;

import java.util.List;

import com.community.common.entity.ParkingSpace;
import com.community.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.community.comsys.mapper.ParkingSpaceMapper;
import com.community.comsys.service.IParkingSpaceService;

/**
 * 车位管理Service业务层处理
 * 
 * @author 潇东
 * @date 2025-10-27
 */
@Service
public class ParkingSpaceServiceImpl implements IParkingSpaceService 
{
    @Autowired
    private ParkingSpaceMapper parkingSpaceMapper;

    /**
     * 查询车位管理
     * 
     * @param parkingSpaceId 车位管理主键
     * @return 车位管理
     */
    @Override
    public ParkingSpace selectParkingSpaceByParkingSpaceId(Long parkingSpaceId)
    {
        return parkingSpaceMapper.selectParkingSpaceByParkingSpaceId(parkingSpaceId);
    }

    /**
     * 查询车位管理列表
     * 
     * @param parkingSpace 车位管理
     * @return 车位管理
     */
    @Override
    public List<ParkingSpace> selectParkingSpaceList(ParkingSpace parkingSpace)
    {
        return parkingSpaceMapper.selectParkingSpaceList(parkingSpace);
    }

    /**
     * 新增车位管理
     * 
     * @param parkingSpace 车位管理
     * @return 结果
     */
    @Override
    public int insertParkingSpace(ParkingSpace parkingSpace)
    {
        parkingSpace.setCreateTime(DateUtils.getNowDate());
        return parkingSpaceMapper.insertParkingSpace(parkingSpace);
    }

    /**
     * 修改车位管理
     * 
     * @param parkingSpace 车位管理
     * @return 结果
     */
    @Override
    public int updateParkingSpace(ParkingSpace parkingSpace)
    {
        parkingSpace.setUpdateTime(DateUtils.getNowDate());
        return parkingSpaceMapper.updateParkingSpace(parkingSpace);
    }

    /**
     * 批量删除车位管理
     * 
     * @param parkingSpaceIds 需要删除的车位管理主键
     * @return 结果
     */
    @Override
    public int deleteParkingSpaceByParkingSpaceIds(Long[] parkingSpaceIds)
    {
        return parkingSpaceMapper.deleteParkingSpaceByParkingSpaceIds(parkingSpaceIds);
    }

    /**
     * 删除车位管理信息
     * 
     * @param parkingSpaceId 车位管理主键
     * @return 结果
     */
    @Override
    public int deleteParkingSpaceByParkingSpaceId(Long parkingSpaceId)
    {
        return parkingSpaceMapper.deleteParkingSpaceByParkingSpaceId(parkingSpaceId);
    }

    /**
     * 导入车位列表
     * @param parkingSpaceList
     * @return
     */
    @Override
    public int importHouseList(List<ParkingSpace> parkingSpaceList) {
        parkingSpaceList.stream().forEach(parkingSpace -> {
            parkingSpace.setCreateTime(DateUtils.getNowDate());
            parkingSpaceMapper.insertParkingSpace(parkingSpace);
        });

        return parkingSpaceList.size();
    }
}
